home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / DS-1.ZIP;1 / DOCS.ZIP / IPD181.DOC < prev   
Encoding:
Text File  |  1992-01-24  |  21.1 KB  |  727 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                  Version 8.5 of Icon for MS-DOS
  8.  
  9.                         Ralph E. Griswold
  10.     Department of Computer Science, The University of Arizona
  11.  
  12.  
  13.  
  14. 1.__Introduction
  15.  
  16.    Version 8.5 of Icon for MS-DOS should run on any computer run-
  17. ning MS-DOS 3.0 or higher.  Math co-processors are supported and
  18. used if present; otherwise software emulation is used.  Approxi-
  19. mate 500K of free RAM is needed to run Icon satisfactorily.  Two
  20. versions of Icon's executor system are provided. One supports
  21. arithmetic on integers of unlimited magnitude and the other does
  22. not. The latter is considerably smaller than the former and can
  23. be used if you do not have enough RAM for the former.
  24.  
  25.    Version 8.5 of Icon for MS-DOS is distributed on 5.25" or 3.5"
  26. diskettes, which include executable binary files, a few test pro-
  27. grams, and documentation in machine-readable form. Printed docu-
  28. mentation is included with diskettes distributed by the Icon Pro-
  29. ject at The University of Arizona.
  30.  
  31.    This implementation of Icon is in the public domain and may be
  32. copied and used without restriction.  The Icon Project makes no
  33. warranties of any kind as to the correctness of this material or
  34. its suitability for any application.  The responsibility for the
  35. use of Icon lies entirely with the user.
  36.  
  37.  
  38. 2.__Documentation
  39.  
  40.    The basic reference for Version 8 of Icon is the second edi-
  41. tion of the bok The Icon Programming Language [1].  This book is
  42. available from the Icon Project at The University of Arizona. It
  43. also can be ordered through any bookstore that handles special
  44. orders.
  45.  
  46.    The new features of Version 8.5 of Icon are in an accompanying
  47. technical report [2].
  48.  
  49.  
  50. 3.__Installing_MS-DOS_Icon
  51.  
  52.    Two executable binary files are needed to run Icon:
  53.  
  54.         icont.exe   translator
  55.         iconx.exe   executor
  56.  
  57. These files should be located at a place on your PATH specifica-
  58. tion.  As mentioned in Section 1, there are two forms of iconx:
  59. one without large-integer arithmetic and one with it.  The former
  60. is named iconx.exe as distributed, while the latter is named
  61.  
  62.  
  63.  
  64. IPD181                        - 1 -             December 29, 1991
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. iconxl.exe.
  74.  
  75.    The distribution is contained in several files in LZH format.
  76. A copy of lharc.exe is included for dearchiving. The distribution
  77. files are:
  78.  
  79.         lharc.exe    dearchiving utility
  80.         icon.lzh     executable binary files [531KB]
  81.         samples.lzh  Icon programs and data [3KB]
  82.         docs.lzh     documents [55KB]
  83.         readme       installation overview and recent notes
  84.  
  85. The figures in brackets give the approximate amount of disk space
  86. needed when the files are extracted from their archives. (It is
  87. not necessary to keep both executors.)
  88.  
  89.    To install the .exe files, set your current directory to the
  90. desired place, place the appropriate distribution diskette in
  91. drive A, and dearchive the files there using lharc.exe.
  92.  
  93.         a:lharc a:icon.lzh
  94.  
  95. The same technique can be used for extracting the remaining
  96. files.
  97.  
  98.    The simplest way to use Icon is to pick the executor that fits
  99. your needs, place it at a location on your path, and rename it to
  100. iconx.exe if necessary. For example, if you want the executor
  101. that supports large-integer arithmetic, the following will do:
  102.  
  103.         rename iconxl.exe iconx.exe
  104.  
  105. However, if you want to use both executors, you can either name
  106. them differently (such as they are named above) and use them by
  107. their different names, or you can name them the same but put them
  108. in different locations. In this case, you will have to change
  109. your path depending on which one you use.
  110.  
  111.  
  112. 4.__Running_MS-DOS_Icon_-_Basic_Information
  113.  
  114.    Files containing Icon programs must have the extension .icn.
  115. Such files should be plain text files (without line numbers or
  116. other extraneous information).  The icont  translator produces an
  117. ``icode'' file that can be executed by iconx.  For example, an
  118. Icon program in the file prog.icn is translated by
  119.  
  120.         icont prog.icn
  121.  
  122. The result is an icode file with the name prog.icx.  This file
  123. can be run by
  124.  
  125.         iconx prog.icx
  126.  
  127.  
  128.  
  129.  
  130. IPD181                        - 2 -             December 29, 1991
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. If your executor is named differently, simply use that name. For
  140. example, if your executor is named iconxl.exe, use
  141.  
  142.         iconxl prog.icx
  143.  
  144. Alternatively, icont can be instructed to execute the icode file
  145. after translation by appending a -x to the command line, as in
  146.  
  147.         icont prog.icn -x
  148.  
  149. This only works if your executor is named iconx.exe, since the -x
  150. option looks for this name.  In the sections that follow, it is
  151. assumed that the executor is named iconx.exe.
  152.  
  153.    If icont is run with the -x option, the file prog.icx is left
  154. and can be run subsequently using an explicitly named executor as
  155. described above.
  156.  
  157.    The extensions .icn and .icx are optional. For example, it is
  158. sufficient to use
  159.  
  160.         icont prog
  161.  
  162. and
  163.  
  164.         iconx prog
  165.  
  166.  
  167.    iconx will find an icode file if it is in the current direc-
  168. tory or at place given on your PATH specification.
  169.  
  170.  
  171. 5.__Testing_the_Installation
  172.  
  173.    There are a few programs on the distribution diskette that can
  174. be used for testing the installation and getting a feel for run-
  175. ning Icon:
  176.  
  177.      hello.icn   This program prints the Icon version number,
  178.                  time, and date. Run this test as
  179.  
  180.                          icont hello
  181.                          iconx hello
  182.  
  183.                  Note that this can be done in one step with
  184.  
  185.                          icont hello -x
  186.  
  187.  
  188.      cross.icn   This program prints all the ways that two words
  189.                  intersect in a common character. The file
  190.                  cross.dat contains typical data. Run this test
  191.                  as
  192.  
  193.  
  194.  
  195.  
  196. IPD181                        - 3 -             December 29, 1991
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.                          icont cross -x <cross.dat
  206.  
  207.  
  208.      meander.icn This program prints the ``meandering strings''
  209.                  that contain all subsequences of a specified
  210.                  length from a given set of characters. Run this
  211.                  test as
  212.  
  213.                          icont meander -x <meander.dat
  214.  
  215.  
  216.      roman.icn   This program converts Arabic numerals to Roman
  217.                  numerals. Run this test as
  218.  
  219.                          icont roman -x
  220.  
  221.                  and provide some Arabic numbers from your con-
  222.                  sole.
  223.  
  224. If these tests work, your installation is probably correct and
  225. you should have a running version of Icon.
  226.  
  227.  
  228. 6.__More_on_Running_Icon
  229.  
  230.    For simple applications, the instructions for running Icon
  231. given in Section 4 may be adequate. The icont translator supports
  232. a variety of options that may be useful in special situations.
  233. There also are several aspects of execution that can be con-
  234. trolled with environment variables.  These are listed here. If
  235. you are new to Icon, you may wish to skip this section on the
  236. first reading but come back to it if you find the need for more
  237. control over the translation and execution of Icon programs.
  238.  
  239. 6.1__Arguments
  240.  
  241.    Arguments can be passed to the Icon program by appending them
  242. to the command line.  Such arguments are passed to the main pro-
  243. cedure as a list of strings.  For example,
  244.  
  245.         iconx prog text.dat log.dat
  246.  
  247. runs the icode file prog.icx, passing its main procedure a list
  248. of two strings, "text.dat" and "log.dat".  The program also can
  249. be translated and run with these arguments with a single command
  250. line by putting the arguments after the -x:
  251.  
  252.         icont prog -x text.dat log.dat
  253.  
  254. These arguments might be the names of files that prog.icn reads
  255. from and writes to. For example, the main procedure might begin
  256. as follows:
  257.  
  258.  
  259.  
  260.  
  261.  
  262. IPD181                        - 4 -             December 29, 1991
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.         procedure main(a)
  272.            in := open(a[1]) | stop("cannot open input file")
  273.            out := open(a[2],"w") | stop("cannot open output file")
  274.                        .
  275.                        .
  276.                        .
  277.  
  278. See also the information about the processing of command-line
  279. arguments given in Section 6.4.
  280.  
  281. 6.2__The_Translator
  282.  
  283.    The icont translator can accept several Icon source files at
  284. one time.  When several files are given, they are translated and
  285. combined into a single icode file whose name is derived from the
  286. name of the first file.  For example,
  287.  
  288.         icont prog1 prog2
  289.  
  290. translates the files prog1.icn and prog2.icn and produces one
  291. icode file, prog1.icx.
  292.  
  293.    A name other than the default one for the icode file produced
  294. by MiconfR can be specified by using the -o option, followed by
  295. the desired name. For example,
  296.  
  297.         icont -o probe.icx prog
  298.  
  299. produces the icode file named probe.icx rather than prog.icx.
  300.  
  301.    If the -c option is given to icont, the translator stops
  302. before producing an icode file and intermediate ``ucode'' files
  303. with the extensions .u1 and .u2 are left for future use (normally
  304. they are deleted).  For example,
  305.  
  306.         icont -c prog1
  307.  
  308. leaves prog1.u1 and prog1.u2, instead of producing prog1.icx.
  309. These ucode files can be used in a subsequent icont command by
  310. using the .u1 name. This saves translation time when the program
  311. is used again.  For example,
  312.  
  313.         icont prog2 prog1.u1
  314.  
  315. translates prog2.icn and combines the result with the ucode files
  316. from a previous translation of prog1.icn. Note that only the .u1
  317. name is given. The extension can be abbreviated to .u, as in
  318.  
  319.         icont prog2 prog1.u
  320.  
  321. Ucode files also can be added to a program using the link
  322. declaration.
  323.  
  324.    Icon source programs may be read from standard input.  The
  325.  
  326.  
  327.  
  328. IPD181                        - 5 -             December 29, 1991
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337. argument - signifies the use of standard input as a source file.
  338. In this case, the ucode files are named stdin.u1 and stdin.u2 and
  339. the icode file is named stdin.icx.
  340.  
  341.    The informative messages from the translator can be suppressed
  342. by using the -s option.  Normally, both informative messages and
  343. error messages are sent to standard error output.
  344.  
  345.    The -t option causes &trace to have an initial value of -1
  346. when the icode file is executed.  Normally, &trace has an initial
  347. value of 0.
  348.  
  349.    The option -u causes warning messages to be issued for unde-
  350. clared identifiers in the program.
  351.  
  352.    Icon has several tables related to the translation of pro-
  353. grams.  These tables are large enough for most programs, but
  354. translation is terminated with an error message, indicating the
  355. offending table, if there is not enough room.  If this happens,
  356. larger table sizes can be specified by using the -S option. This
  357. option has the form -S[cfgilnrstCFL]n, where the letter following
  358. the S specifies the table and n is the number of storage units to
  359. allocate for it.
  360.  
  361.      c  constant table          100
  362.      f  field table             100
  363.      g  global symbol table     200
  364.      i  identifier table        500
  365.      l  local symbol table      100
  366.      n  line number table      1000
  367.      r  record table            100
  368.      s  string space          20000
  369.      t  tree space            15000
  370.      C  code buffer           15000
  371.      F  file names               10
  372.      L  labels                  500
  373.  
  374. The units depend on the table involved, but the default values
  375. can be used as guides for appropriate settings of -S options
  376. without knowing the units.  For example,
  377.  
  378.         icont -Sc200 -Sg600 prog
  379.  
  380. translates prog.icn with twice the constant table space and three
  381. times the global symbol table space that ordinarily would be pro-
  382. vided.
  383.  
  384. 6.3__Environment_Variables
  385.  
  386.    When an icode file is executed, several environment variables
  387. are examined to determine execution parameters.  The values
  388. assigned to these variables should be numbers.
  389.  
  390.    Environment variables are particularly useful in adjusting
  391.  
  392.  
  393.  
  394. IPD181                        - 6 -             December 29, 1991
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403. Icon's storage requirements.  Particular care should be taken
  404. when changing default values: unreasonable values may cause Icon
  405. to malfunction.
  406.  
  407.    The following environment variables can be set to adjust
  408. Icon's execution parameters. Their default values are listed in
  409. parentheses after the environment variable name:
  410.  
  411.         TRACE (undefined).  This variable initializes the value
  412.      of &trace.  If this variable has a value, it overrides the
  413.      translation-time -t option.
  414.  
  415.         NOERRBUF (undefined).  If this variable is set, &errout
  416.      is not buffered.
  417.  
  418.         STRSIZE (65000). This variable determines the size, in
  419.      bytes, of the region in which strings are stored.  If addi-
  420.      tional string regions are needed, they may be smaller.
  421.  
  422.         BLKSIZE (65000).  This variable determines the size, in
  423.      bytes, of the region in which Icon allocates lists, tables,
  424.      and other objects.  If additional block regions are needed,
  425.      they may be smaller.
  426.  
  427.         COEXPSIZE (2000). This variable determines the size, in
  428.      32-bit words, of each co-expression block.
  429.  
  430.         MSTKSIZE (10000). This variable determines the size, in
  431.      words, of the main interpreter stack.
  432.  
  433.         QLSIZE (5000). This variable determines the size, in
  434.      bytes, of the region used by the garbage collector for
  435.      pointers to strings.
  436.  
  437.    The maximum region size that can be specified is 65000.
  438.  
  439. 6.4__Details_of_Command-Line_Processing
  440.  
  441.    The processing of command-line arguments normally is important
  442. only in running iconx. Some details follow:
  443.  
  444.      +  An argument containing white space must be enclosed in
  445.         double quotes.  For example, "abc def" is a valid argu-
  446.         ment. The quotes are deleted in the string passed to
  447.         iconx.
  448.  
  449.      +  If a quoted argument contains a double quote, the embed-
  450.         ded quote must be preceded by a backslash. For example,
  451.         "abc de\"f" is a valid argument. The outer quotes and the
  452.         backslash are deleted in the string passed to iconx.
  453.  
  454.      +  If a non-quoted argument contains a double quote, the
  455.         embedded quote can be preceded by a backslash or not. For
  456.         example, abc\"d and abc"d are equivalent arguments.
  457.  
  458.  
  459.  
  460. IPD181                        - 7 -             December 29, 1991
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.      +  To pass a lone double quote as an argument, precede it
  470.         with a backslash.
  471.  
  472.      +  Wild-card characters are not expanded.
  473.  
  474.      +  Quote-balancing errors are not checked.  The start-up
  475.         routine scans the residual command line from left to
  476.         right.
  477.  
  478.  
  479. 7.__Features_of_MS-DOS_Icon
  480.  
  481.    MS-DOS Icon supports all the features of Version 8.5 of Icon,
  482. with the following exceptions and additions:
  483.  
  484.      +  Pipes are not supported. A file cannot be opened with the
  485.         "p" option.
  486.  
  487.      +  For files opened in the translate mode, the position pro-
  488.         duced by seek() may not reflect the actual byte position
  489.         because of the translation of carriage-return/line-feed
  490.         sequences to line-feed characters.
  491.  
  492.      +  Path specifications can be entered using either a / or a
  493.         \. Examples are:
  494.  
  495.                 A:\ICON\TEST.ICN
  496.                 A:/ICON/TEST.ICN
  497.  
  498.  
  499.      +  The following MS-DOS device names can be used as file
  500.         names:
  501.  
  502.                 console        CON
  503.                 printer        PRN LST LPT LPT1
  504.                 auxiliary port AUX COM RDR PUN
  505.                 null           NUL NULL
  506.  
  507.         For example,
  508.  
  509.                 prompt := open("CON", "w")
  510.  
  511.         causes strings written to prompt to be displayed on the
  512.         console.  Use of a null file name means no file is
  513.         created.
  514.  
  515.      +  MS-DOS Icon also has some functions in addition to the
  516.         standard repertoire.  These are described in the next
  517.         section.
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526. IPD181                        - 8 -             December 29, 1991
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535. 8.__MS-DOS_Functions
  536.  
  537.    Disclaimer: The following functions provide a gateway to
  538. facilities provided by MS-DOS and ROM BIOS. These functions
  539. should be used with care, since Icon maintains strict control
  540. over its environment (although it uses standard MS-DOS interfaces
  541. and does not bypass MS-DOS or ROM BIOS in any way).  The descrip-
  542. tions that follow are low-level descriptions. They assume
  543. knowledge of the Intel 8086 (8088, 80x86) architecture.
  544.  
  545. Int86(L):
  546.  
  547. Int86(L) generates a hardware interrupt. The input is a list of
  548. integer values: [interrupt number, ax, bx, cx, dx, si, di, es,
  549. ds].  It returns a list of the form [flags, ax, bx, cx, dx, si,
  550. di, es, ds].
  551.  
  552.    Great care must be taken in using this function. Some things
  553. to watch out for are:
  554.  
  555.      +  Interrupt functions that alter the stack registers (SS or
  556.         SP) or alter the MS-DOS memory chain (that is, allocate
  557.         or deallocate memory in the MS-DOS memory region). When
  558.         Icon expands memory, it expects the next allocation to be
  559.         contiguous with the region it currently owns.
  560.  
  561.      +  Interrupt functions that operate on files opened by
  562.         Icon's open(s) function - that is, closing, seeking,
  563.         reading, or writing.
  564.  
  565.      +  The values of ES and DS may not be valid on return.
  566.  
  567.  
  568. InPort(i):
  569.  
  570. InPort(i) returns an integer from hardware port i.
  571.  
  572. OutPort(i1,i2):
  573.  
  574. OutPort(i1,i2) writes value i2 to hardware port i1.
  575.  
  576. GetSpace(i):
  577.  
  578. GetSpace(i) allocates a static block of storage outside of Icon's
  579. direct control (that is, it is not be affected by garbage collec-
  580. tion).  This function simply calls the malloc() allocation rou-
  581. tine and returns the address of the resulting block as a long
  582. integer.
  583.  
  584. FreeSpace(A):
  585.  
  586. FreeSpace(A) frees a static block of storage, where A is a value
  587. returned by GetSpace(i).  No check is make to verify that the
  588. block was allocated by GetSpace(i). The results are unpredictable
  589.  
  590.  
  591.  
  592. IPD181                        - 9 -             December 29, 1991
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601. if it was not.  Arithmetic should not be performed directly on a
  602. value returned by GetSpace(i).
  603.  
  604. Peek(A,i):
  605.  
  606. Peek(A,i) builds a string pointing to the address specified by A
  607. with a length of i, where A is either an integer that specifies a
  608. linear address value or a list of the form [segment, offset] and
  609. i is a length (default 1).
  610.  
  611.    This is the only way of `seeing' the contents of a block of
  612. storage allocated by GetSpace(i). Consider the following example:
  613.  
  614.         block := Peek(addr := GetSpace(100),100)
  615.  
  616. The value of block is a string of length 100 and addr is the
  617. linear address of the block.
  618.  
  619. Peek(A,i) does not move data into Icon's memory region.  Instead,
  620. it builds a string qualifier that points to the data.
  621.  
  622. Poke(A,s):
  623.  
  624. Poke(A,s) copies a string s to location A, where A is an address
  625. specified in the same way as for Peek(A,s) and s is a string to
  626. be copied to that storage location. The string is copied directly
  627. into storage, byte by byte. No conversion is performed.  This is
  628. the only way of assigning data to a block of storage allocated by
  629. GetSpace(i).
  630.  
  631.  
  632. 9.__Known_Bugs
  633.  
  634.    A list of known bugs in Icon itself is given in [2].
  635.  
  636.    MS-DOS memory management also can cause problems.  Some pro-
  637. grams that require a lot of memory may hang when run by the -x
  638. option to icont.  This can be avoided by using iconx in a
  639. separate step.  Also, if there is not enough free RAM, the sys-
  640. tem() function may fail silently or hang.
  641.  
  642.  
  643. 10.__Reporting_Problems
  644.  
  645.    Problems with Icon should be noted on a trouble report form
  646. (included with the distribution) and sent to
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658. IPD181                       - 10 -             December 29, 1991
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.         Icon Project
  668.         Department of Computer Science
  669.         Gould-Simpson Building
  670.         The University of Arizona
  671.         Tucson, AZ   85721
  672.         U.S.A.
  673.         (602) 621-8448 (voice)
  674.         (602) 621-4246 (fax)
  675.         icon-project@cs.arizona.edu     (Internet)
  676.         ... {uunet, allegra, noao}!arizona!icon-project     (uucp)
  677.  
  678.  
  679.  
  680. 11.__Registering_Copies_of_Icon
  681.  
  682.    If you received your copy of Icon directly from the Icon Pro-
  683. ject, it has been registered in your name and you will automati-
  684. cally receive the Icon Newsletter.  This newsletter contains
  685. information about new implementations, updates, programming tech-
  686. niques, and information of general interest about Icon.
  687.  
  688.    If you received your copy of Icon from another source, please
  689. fill out the registration form that is included in the distribu-
  690. tion and send it to the Icon Project at the address listed above.
  691. This will assure that you receive the Icon Newsletter and infor-
  692. mation about updates.
  693.  
  694. Acknowledgements
  695.  
  696.    The design and implementation of the Icon programming language
  697. was supported, in part, by grants from the National Science Foun-
  698. dation.
  699.  
  700.    Clint Jeffery, Gregg Townsend, and Ken Walker collaborated
  701. with the author in the development of Version 8.5.
  702.  
  703. References
  704.  
  705.  
  706. 1.   R. E. Griswold and M. T. Griswold, The Icon Programming
  707.      Language, Prentice-Hall, Inc., Englewood Cliffs, NJ, second
  708.      edition, 1990.
  709.  
  710. 2.   R. E. Griswold, C. L. Jeffery, G. M. Townsend and K. Walker,
  711.      Version 8.5 of the Icon Programming Language, The Univ. of
  712.      Arizona Icon Project Document IPD174, 1992.
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724. IPD181                       - 11 -             December 29, 1991
  725.  
  726.  
  727.